import java.util.Scanner;

class Solution {
    static class TreeNode{
        public char val;
        public TreeNode left;
        public TreeNode right;
        public TreeNode(char val){
            this.val = val;
        }
    }




    //二叉树的遍历
    public int i = 0;
    public TreeNode createTree(String s){
        TreeNode root = null;
        if (s.charAt(i) != '#'){
            root = new TreeNode(s.charAt(i));
            i++;
            root.left = createTree(s);
            root.right = createTree(s);
        }else{
            i++;
        }
        return root;
    }
    public  void inOrder(TreeNode root){
        if (root == null) return;
        inOrder(root.left);
        System.out.print(root.val+" ");
        inOrder(root.right);
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNextLine()){
            String s = scanner.nextLine();
            Solution solution = new Solution();
            TreeNode root = solution.createTree(s);
            solution.inOrder(root);
        }
    }
}
